package io.renren.modules.generator.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.controller.BaseController;
import io.renren.modules.generator.controller.vo.EnterpriseSupervisionBackPaySaveVo;
import io.renren.modules.generator.entity.EnterpriseSupervisionBackPayRecordEntity;
import io.renren.modules.generator.service.EnterpriseSupervisionBackPayRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;


/**
 * 企业欠薪巡查记录表
 *
 * @author zd
 * @date 2020-09-22 00:23:11
 */
@Validated
@RestController
@RequestMapping("generator/backPay")
@Api(value = "企业欠薪巡查记录表接口",tags = "企业欠薪巡查记录表接口")
public class EnterpriseSupervisionBackPayRecordController extends BaseController {

    @Autowired
    private EnterpriseSupervisionBackPayRecordService enterpriseSupervisionBackPayRecordService;

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("保存")
    public R save(@Valid @RequestBody EnterpriseSupervisionBackPaySaveVo vo){
        vo.setUserNo(getUserNo());
        vo.setUserName(getUserName());
        enterpriseSupervisionBackPayRecordService.saveBackPayEntity(vo);
        return R.ok();
    }

    /**
     * 列表
     */
    @RequestMapping("/page")
    @ApiOperation("分页列表")
    public R queryPage(@RequestParam Map<String, Object> params,@RequestParam(value = "",required = false,defaultValue = "") String keyword){
        PageUtils page = enterpriseSupervisionBackPayRecordService.queryPage(params,keyword,getDeptId());
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info")
    @ApiOperation("根据id获取实体")
    public R info(Integer id) {
		EnterpriseSupervisionBackPayRecordEntity enterpriseSupervisionBackPayRecord = enterpriseSupervisionBackPayRecordService.getById(id);
        return R.ok().put("model", enterpriseSupervisionBackPayRecord);
    }
}
